package com.poorstu.web.auditaction;

import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.common.base.web.BaseAction;
import com.poorstu.manager.PoorStudentManager;
import com.poorstu.manager.StudentManager;
import com.poorstu.model.LoginMod;
import com.poorstu.model.StuPoorMod;

public class AuditStuPoorShowAction extends BaseAction {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
				try{
					
		int poorStuId=Integer.parseInt(request.getParameter("stupoorId"));
		PoorStudentManager poorStudentManager=(PoorStudentManager)getBean("poorStudentManager");
		StuPoorMod stuPoorMod=poorStudentManager.selectPootStuById(poorStuId);
		request.setAttribute("stuPoorMod", stuPoorMod);
		
		
		
		int allUserId=stuPoorMod.getAudits().getLogins().getId();
		StudentManager stu =(StudentManager)getBean("studentManager");
		LoginMod login=stu.selectStudentById(allUserId);
		request.setAttribute("login", login);
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String birthday= sdf.format(login.getStu().getAges());
		request.setAttribute("birthday", birthday);
		
		return mapping.findForward("succ");
				}catch(Exception e){
					e.printStackTrace();
					
				}
		
				return mapping.findForward("failure");
	}
	

	
}
